//
//  SafeSpecialTypeCell.m
//  Estate
//
//  Created by wangdongdong on 2017/10/9.
//  Copyright © 2017年 ttsx. All rights reserved.
//

#import "SafeSpecialTypeCell.h"

@implementation SafeSpecialTypeCell

- (void)awakeFromNib {
    [super awakeFromNib];

    self.leftView.backgroundColor = UIColorFromRGB(0x009688);
    self.numberLabel.textColor = UIColorFromRGB(0x676767);
    [self.deleteBtn setTitleColor:UIColorFromRGB(0xff0000) forState:UIControlStateNormal];
    self.lineView.backgroundColor = UIColorFromRGB(0xdddddd);
    
    // 所属工种
    self.workTypeLabel.textColor = UIColorFromRGB(0x343434);
    [self.workTypeBtn setTitleColor:UIColorFromRGB(0xaaaaaa) forState:UIControlStateNormal];
    self.workTypeBtn.layer.cornerRadius = 5;
    self.workTypeBtn.layer.borderColor = UIColorFromRGB(0xdddddd).CGColor;
    self.workTypeBtn.layer.borderWidth = 0.6f;
    
    // 施工申报人数
    self.filingsLabel.textColor = UIColorFromRGB(0x343434);
    self.filingsField.textColor = UIColorFromRGB(0x343434);
    self.filingsField.delegate = self;
    self.filingsField.tag = 1000;
    [self.filingsField addTarget:self action:@selector(textField1TextChange:) forControlEvents:UIControlEventEditingChanged];

    
    // 核查实际人数
    self.CheckNumberLabel.textColor = UIColorFromRGB(0x343434);
    self.CheckNumberField.textColor = UIColorFromRGB(0x343434);
    self.CheckNumberField.delegate = self;
    self.CheckNumberField.tag = 2000;
    [self.CheckNumberField addTarget:self action:@selector(textField1TextChange:) forControlEvents:UIControlEventEditingChanged];
    
    // 有效证书人数
    self.EffectiveNumberLabel.textColor = UIColorFromRGB(0x343434);
    self.EffectiveNumberField.textColor = UIColorFromRGB(0x343434);
    self.EffectiveNumberField.delegate = self;
    self.EffectiveNumberField.tag = 3000;
    [self.EffectiveNumberField addTarget:self action:@selector(textField1TextChange:) forControlEvents:UIControlEventEditingChanged];
    
    // 不符合人数
    self.nonconformityLabel.textColor = UIColorFromRGB(0x343434);
    self.nonconformityField.textColor = UIColorFromRGB(0x343434);
    self.nonconformityField.delegate = self;
    self.nonconformityField.tag = 4000;
    [self.nonconformityField addTarget:self action:@selector(textField1TextChange:) forControlEvents:UIControlEventEditingChanged];
    
    // 符合率
    self.CoincidenceRateLabel.textColor = UIColorFromRGB(0x343434);
    self.CoincidenceRateValue.textColor = UIColorFromRGB(0x343434);
    
    // 检查意见或整改要求
    self.CheckOpinionLabel.textColor = UIColorFromRGB(0x343434);
    self.CheckOpinionText.layer.borderColor = [[UIColor colorWithRed:215.0 / 255.0 green:215.0 / 255.0 blue:215.0 / 255.0 alpha:1] CGColor];
    self.CheckOpinionText.layer.borderWidth = 0.6f;
    self.CheckOpinionText.layer.cornerRadius = 6.0f;
    self.CheckOpinionText.delegate = self;
    
    // 数字键盘
    self.filingsField.keyboardType = UIKeyboardTypeNumberPad;
    self.CheckNumberField.keyboardType = UIKeyboardTypeNumberPad;
    self.EffectiveNumberField.keyboardType = UIKeyboardTypeNumberPad;
    self.nonconformityField.keyboardType = UIKeyboardTypeNumberPad;
}

// 不可编辑
- (void)isNoEdit {
    self.deleteBtn.enabled = NO;
    self.workTypeBtn.enabled = NO;
    self.filingsField.enabled = NO;
    self.CheckNumberField.enabled = NO;
    self.EffectiveNumberField.enabled = NO;
    self.nonconformityField.enabled = NO;
    self.CheckOpinionText.editable = NO;
}

#pragma mark UITextFieldDelegate
- (void)textField1TextChange:(UITextField *)textField {
    
    // 施工申报人数
    if (textField.tag == 1000) {
        if (self.filingsBlock) {
            self.filingsBlock(textField.text);
        }
        
    // 核查实际人数
    } else if (textField.tag == 2000) {
        if (self.checkNumberBlock) {
            self.checkNumberBlock(textField.text);
        }
        
    // 有效证书人数
    } else if (textField.tag == 3000) {
        if (self.effectiveNumberBlock) {
            self.effectiveNumberBlock(textField.text);
        }
        
    // 不符合人数
    } else if (textField.tag == 4000) {
        if (self.nonconformityBlock) {
            self.nonconformityBlock(textField.text);
        }
    }
}

#pragma mark UITextViewDelegate(检查意见/整改要求)
- (void)textViewDidChange:(UITextView *)textView {
    if (self.checkOpinionBlock) {
        self.checkOpinionBlock(textView.text);
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


@end

